package com.umakr.demo.controller;

import com.umakr.demo.model.Combobox;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by yangliu on 2017/8/2.
 */
@RequestMapping("/test03")
@Controller
public class Controller03 {

    @RequestMapping("/day03")
    public ModelAndView stop() {
        ModelAndView mav = new ModelAndView();
        mav.setViewName("day03/test");
        return mav;
    }

    @RequestMapping("/ajax")
//    @ResponseBody
    public ModelAndView show() {
        List<Combobox.User> list = new ArrayList<Combobox.User>();
        for (int i = 0; i <= 10; i++) {
            Combobox.User user = new Combobox.User();
            user.setId(i + 1);
            user.setName("ajax" + i);
            user.setAge(i + 20);
            list.add(user);
        }
        ModelAndView mav = new ModelAndView();
        mav.addObject("clist",list);
        mav.setViewName("day03/test.jsp");
        return  mav;
    }
}